package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldRestbreaksDto;
import com.cleaningcloud.cld.domain.vo.CldRestbreaksVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.service.ICldRestbreaksService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 排休管理Controller
 * 
 * @author cleaningcloud
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/restbreaks")
public class CldRestbreaksController extends BaseController
{
    @Autowired
    private ICldRestbreaksService cldRestbreaksService;

    /**
     * 查询排休管理列表
     */
    @RequiresPermissions("cld:restbreaks:list")
    @GetMapping("/list")
    public TableDataInfo list(CldRestbreaksDto cldRestbreaks)
    {
        startPage();
        List<CldRestbreaksVo> list = cldRestbreaksService.selectCldRestbreaksList(cldRestbreaks);
        return getDataTable(list);
    }

//    /**
//     * 导出排休管理列表
//     */
//    @RequiresPermissions("cld:restbreaks:export")
//    @Log(title = "排休管理", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, CldRestbreaks cldRestbreaks)
//    {
//        List<CldRestbreaks> list = cldRestbreaksService.selectCldRestbreaksList(cldRestbreaks);
//        ExcelUtil<CldRestbreaks> util = new ExcelUtil<CldRestbreaks>(CldRestbreaks.class);
//        util.exportExcel(response, list, "排休管理数据");
//    }

    /**
     * 获取排休管理详细信息
     */
    @RequiresPermissions("cld:restbreaks:query")
    @GetMapping(value = "/{restbreakId}")
    public AjaxResult getInfo(@PathVariable("restbreakId") Long restbreakId)
    {
        return success(cldRestbreaksService.selectCldRestbreaksByRestbreakId(restbreakId));
    }


    /**
     * 列表查看项目排休一览
     */
    @RequiresPermissions("cld:restbreaks:query")
    @GetMapping(value = "/getTableCalendarList/{restbreakId}")
    public AjaxResult getTableCalendarList(@PathVariable("restbreakId") Long restbreakId)
    {
        return success(cldRestbreaksService.getTableCalendarList(restbreakId));
    }

    /**
     * 日历查看员工排休一览
     */
    @RequiresPermissions("cld:restbreaks:query")
    @GetMapping(value = "/getCalendarByStaffId")
    public AjaxResult getCalendarByStaffId(CldRestbreaksDto cldRestbreaksDto)
    {
        return success(cldRestbreaksService.getCalendarByStaffId(cldRestbreaksDto));
    }

    /**
     * 新增排休管理
     */
    @RequiresPermissions("cld:restbreaks:add")
    @Log(title = "排休管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldRestbreaksDto cldRestbreaks)
    {
        return toAjax(cldRestbreaksService.insertCldRestbreaks(cldRestbreaks));
    }

    /**
     * 修改排休管理
     */
    @RequiresPermissions("cld:restbreaks:edit")
    @Log(title = "排休管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldRestbreaksDto cldRestbreaks)
    {
        return toAjax(cldRestbreaksService.updateCldRestbreaks(cldRestbreaks));
    }

    /**
     * 删除排休管理
     */
    @RequiresPermissions("cld:restbreaks:remove")
    @Log(title = "排休管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{restbreakIds}")
    public AjaxResult remove(@PathVariable Long[] restbreakIds)
    {
        return toAjax(cldRestbreaksService.deleteCldRestbreaksByRestbreakIds(restbreakIds));
    }
}
